package com.zgkxzx.设计模式.状态;

/**
 * 创建者   zgkxzx
 * 创建日期 2018/5/12.
 * 功能描述
 */
public class StatusMachine implements BaseStatus {

    BaseStatus currentStatus;

    BaseStatus firstStatus;
    BaseStatus secondStatus;
    BaseStatus thirdStatus;


    public StatusMachine() {
        firstStatus = new FirstStatus();
        secondStatus = new SecondStatus();
        thirdStatus = new ThirdStatus();

        currentStatus = firstStatus;
    }

    @Override
    public void step1() {
        currentStatus.step1();
    }

    @Override
    public void step2() {
        currentStatus.step2();
    }

    @Override
    public void step3() {
        currentStatus.step3();
    }


    public void changeStatus() {
        if (currentStatus == firstStatus)
            currentStatus = secondStatus;
        else if (currentStatus == secondStatus)
            currentStatus = thirdStatus;
    }
}
